package cate.common.table.dynins;


import cate.common.annotation.SplitParse;
import cate.common.table.ERow;
import cate.common.table.XSSFRowWrap;
import cate.common.table.d.GDHero;
import cate.common.util.SplitParser;
import easy.java.dev.note.NoteClass;

import java.util.List;

@NoteClass("星格映射")
public class DynSpiceRow extends ERow {

    private String j1Str;
    private String j2Str;
    private String j3Str;
    private String j4Str;

    @Override
    public void parse(XSSFRowWrap xrw) {
        super.parse(xrw);
        this.id = xrw.getInteger("强度等级", -1);
        this.j1Str = xrw.getString("战士");
        this.j2Str = xrw.getString("法师");
        this.j3Str = xrw.getString("坦克");
        this.j4Str = xrw.getString("辅助");
    }

    private List<Config> j1;
    private List<Config> j2;
    private List<Config> j3;
    private List<Config> j4;


    @Override
    public void decode() {
        j1 = SplitParser.parse(Config.class, j1Str);
        j2 = SplitParser.parse(Config.class, j2Str);
        j3 = SplitParser.parse(Config.class, j3Str);
        j4 = SplitParser.parse(Config.class, j4Str);
    }

    public List<Config> getConfig(byte job) {
        switch (job) {
            case GDHero.Job.J1:
                return j1;
            case GDHero.Job.J2:
                return j2;
            case GDHero.Job.J3:
                return j3;
            case GDHero.Job.J4:
                return j4;
            default:
                return null;
        }
    }

    // 位置：星格id：等级
    public static class Config {
        @SplitParse(order = 0, defaultValue = "0", note = "位置")
        public byte pos;
        @SplitParse(order = 1, defaultValue = "0", note = "星格id")
        public int tid;
        @SplitParse(order = 2, defaultValue = "0", note = "等级")
        public int level;
    }
}
